{% extends "base.html" %}
{% block content %}
</div>
<div class="col-md-12">
<table class="table">
    <tr>
        <th>ID</th>
        <th>用戶名</th>
        <th>來源平台</th>
        <th>註冊時間</th>
        <th>登錄時間</th>
        <th>登錄IP</th>
        <th>簡述</th>
        <th>操作</th>
    </tr>
    {% for user in users %}
    <tr>
        <td>{{user.id}}</td>
        <td>
            <img src='{{user.avatar}}' height=32 width=32 />
            {{user.username}}
        </td>
        <td>{{user.social_auth[0].provider}}</td>
        <td>{% if user.create_time %}{{user.create_time.strftime("%Y-%m-%d %H:%M:%S")}}{% endif %}</td>
        <td>{% if user.access_time %}{{user.access_time.strftime("%Y-%m-%d %H:%M:%S")}}{% endif %}</td>
        <td>{{user.extra.login_ip}}</td>
        <td>
            {% if user.extra.visit_history    %} {{user.extra.visit_history|length}}訪問    {% endif %}
            {% if user.extra.read_history     %} {{user.extra.read_history|length}}閱讀     {% endif %}
            {% if user.extra.push_history     %} {{user.extra.push_history|length}}推送     {% endif %}
            {% if user.extra.download_history %} {{user.extra.download_history|length}}下載 {% endif %}
            {% if user.extra.upload_history   %} {{user.extra.upload_history|length}}上傳   {% endif %}
        </td>
        <td>
            <a class="btn" href="/admin/set?user_id={{user.id}}">Enter</a>
        </td>
    </tr>
    {% endfor %}
</table>
<ul class="pagination">
    {% if 0 not in pages %}
    <li><a href="?sort={{sort}}">1</a></li>
    {% if 1 not in pages %}
    <li class="disabled"><a href="#">...</a></li>
    {% endif %}
    {% endif %}

    {% for p in pages %}
    <li {%if page_now == p %}class="active"{%endif%}><a href="?sort={{sort}}&start={{p*delta}}">{{p+1}}</a></li>
    {% endfor %}

    {% if page_max not in pages %}
    {% if page_max -1 not in pages %}
    <li class="disabled"><a href="#">...</a></li>
    {% endif %}
    <li><a href="?sort={{sort}}&start={{page_max*delta}}">{{page_max+1}}</a></li>
    {% endif %}
</ul>
</div>
<div>
{% endblock %}

{% block sidebar %}
{% endblock %}
